package team.headnurse.nursemanagement.service.impl;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import team.headnurse.nursemanagement.dao.DepartmentDao;
import team.headnurse.nursemanagement.model.Department;
import team.headnurse.nursemanagement.service.DepartmentService;

import javax.annotation.Resource;

/**
 * @author Eugene-Forest
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Resource
    private DepartmentDao departmentDao;

    /**
     * 插入一条科室记录数据
     *
     * @param department 科室记录对象
     * @return 成功则返回1
     */
    @Override
    public int insert(Department department) {
        if (department!=null){
            return departmentDao.insert(department);
        }
        return 0;
    }

    /**
     * 更新科室表记录
     *
     * @param department 科室记录对象
     * @return 成功则返回1
     */
    @Override
    public int update(Department department) {
        if (department!=null){
            return departmentDao.update(department);
        }
        return 0;
    }

    /**
     * 通过 科室记录对象 删除一条科室表记录
     *
     * @param department 科室记录对象
     * @return 成功则返回1
     */
    @Override
    public int delete(Department department) {
        if (department!=null){
            return departmentDao.delete(department);
        }
        return 0;
    }

    /**
     * 通过 科室id 删除一条科室表记录
     *
     * @param departmentId 科室id
     * @return 成功则返回1
     */
    @Override
    public int deleteById(String departmentId) {
        return departmentDao.deleteById(departmentId);
    }

    /**
     * 通过 科室id 查找科室名称
     *
     * @param departmentId 科室id
     * @return 科室名称
     */
    @Override
    public Department selectById(String departmentId) {
        return departmentDao.selectById(departmentId);
    }
}
